package com.aaa.hospital.controller;

import com.aaa.hospital.aop.Log;
import com.aaa.hospital.pojo.query.DoctorQuery;
import com.aaa.hospital.pojo.vo.DoctorVO;
import com.aaa.hospital.result.AjaxResult;
import com.aaa.hospital.service.DoctorService;
import com.aaa.hospital.util.OSSUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * 张骞做的医生管理
 *
 * @author ZQ on 2022/1/9
 */
@RestController
@RequestMapping("doctor")
public class DoctorController {



    @Autowired
    private DoctorService doctorService;

    @Autowired
    private OSSUtil ossUtil;



    @RequestMapping("doctorsList")
    public AjaxResult doctorsList() {

        return doctorService.doctorList();
    }

    @RequestMapping("doctorQuery")
    public AjaxResult doctorsQuery(DoctorQuery doctorQuery) {

        return doctorService.doctorsQuery(doctorQuery);
    }

    @RequestMapping("getKes")
    public AjaxResult getKes() {

        return doctorService.getKes();
    }

    @RequestMapping("getPost")
    public AjaxResult getPost() {

        return doctorService.getPost();
    }

    @RequestMapping("getRole")
    public AjaxResult getRole() {

        return doctorService.getRole();
    }

    @RequestMapping("addDoctors")
    @Log("添加医生")
    public AjaxResult addDoctors(DoctorVO doctorVO, MultipartFile headImg) {
        String path = ossUtil.uploadOSS(headImg);
        doctorVO.setImgURL(path);

        return doctorService.addDoctor(doctorVO);
    }

    @RequestMapping("deleteDoctor/{id}")
    @Log("删除医生")
    public AjaxResult deleteDoctor(@PathVariable("id") Integer id) {

        return doctorService.deleteDoctor(id);
    }

    @RequestMapping("getDoctor/{id}")
    public AjaxResult getDoctor(@PathVariable("id") Integer id) {

        return doctorService.getDoctor(id);
    }
    @RequestMapping("updateDoctor")
    @Log("修改医生")
    public AjaxResult updateDoctor(DoctorVO doctorVO) {

        return doctorService.updateDoctor(doctorVO);
    }

    @RequestMapping("doctorsResume/{id}")
    public AjaxResult doctorResume(@PathVariable("id") Integer id) {

        return doctorService.doctorResume(id);
    }
}